const router = require('koa-router')();
const Koa = require('koa');
const app = new Koa();

router.get('/pay', async (ctx, next) => {


  const appid = "3a4b817c-0cb7-4f77-8611-6e31f45be82c";
	const secret = "b78ba509-1e81-40ad-a735-66cc8174124d";
	let title = "中文 node.js water"
	let amount = "100"

	let uuid = require('node-uuid');
	let outTradeNo = uuid.v4();
	outTradeNo = outTradeNo.replace(/-/g, '');

	let data = appid + title + amount + outTradeNo + secret;
	let sign = require('crypto');
	let signStr = sign.createHash('md5').update(data, 'utf8').digest("hex");

  await ctx.render('pay/index', { title: '小主支付', OutTradeNo: outTradeNo, Sign: signStr,amount:amount});


})



router.get('/pay/ok', async (ctx, next) => {


       console.log('支付成功')


})



module.exports = router